home *** CD-ROM | disk | FTP | other *** search
- @echo off
- ! extractName.bat Extract a file or folder name from a full DOS path
- !
- ! extractName path [varName]
- !
- ! where 'path' is the full path from which the item name is to be extracted
- ! and 'varName' is a string containing the name of the global variable into
- ! which the item name is to be returned. If 'varName' is missing, extractName
- ! displays the name in the console window.
- !
- ! Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
- !
-
- ! ensure that the first parameter is there and that the third one is not
- set doserr=13
- if not "%3 " == " " goto ERR_LBL
- if "%1 " == " " goto ERR_LBL
-
- ! extract the name into a temporary variable
- set extractName_name=%1
- onerror SKIP_LBL
- sstr/e/r extractName_name "\"
- :SKIP_LBL
- onerror SKIP2_LBL
- sstr/e/r extractName_name ":"
- :SKIP2_LBL
-
- ! if the second parameter is there, store the name into the requested variable,
- ! otherwise just display the result
- if "%2 " == " " goto DISPLAY_LBL
- set %2=%extractName_name%
- set doserr=0
- goto DONE_LBL
-
- :DISPLAY_LBL
- echo %QUOTE%%extractName_name%%QUOTE%
- set doserr=0
- goto DONE_LBL
-
- :ERR_LBL
- show %doserr%
-
- :DONE_LBL
- ! remove the temporary variable
- set extractName_name=
-